Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added bulk mode UDP #75

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ethouris
Copy link
Contributor

Added "bulk mode" UDP reader. This is implemented as a separate socket::mudp class which uses recvmmsg for reading multiple packets if available.

Packets are stored in a local buffer and are returned from cache. The call to the system function refills the cache.

Available only on Linux.

You need to enable it (instead of the standard UDP reader) by --udp-mode bulk option.

class udp
: public std::enable_shared_from_this<udp>
, public isocket
class udp_base

Check warning

Code scanning / CodeQL

Non-virtual destructor in base class

A base class with a virtual function should define a virtual destructor.
Comment on lines +267 to +273
/* TRACE - enable if necessary for development
for (int i = 0; i < res; ++i)
{
std::cout << "[" << (*bufsizes[i]) << "]";
}
std::cout << std::endl;
*/

Check notice

Code scanning / CodeQL

Commented-out code

This comment appears to contain commented-out code.
Comment on lines +190 to +194
if (val[0] == "bulk")
::xtransmit::g_udp_mode_bulk = true;
return true;
},
"UDP mode: simple or bulk [Linux only]");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To detect possible typos (if returning false results in an error):

else if (val[0] != "simple")
    return false;

udp(const UriParser &src_uri);
~udp();
udp_base(const UriParser &src_uri);
~udp_base();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
~udp_base();
virtual ~udp_base();

Comment on lines +220 to +235
while (!m_blocking_mode)
{
fd_set set;
timeval tv;
FD_ZERO(&set);
FD_SET(m_bind_socket, &set);
tv.tv_sec = 0;
tv.tv_usec = 10000;
const int select_ret = ::select((int)m_bind_socket + 1, &set, NULL, &set, &tv);

if (select_ret != 0) // ready
break;

if (timeout_ms >= 0) // timeout
return 0;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to block if there is a cached buffer to read.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants